home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 417 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  3.4 KB

  1. Path: chronicle.mti.sgi.com!austern
  2. From: phalpern@truffle.ultranet.com (Pablo Halpern)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: An STL helper -- and template and type shenanigans
  5. Date: 21 Feb 1996 09:56:42 PST
  6. Organization: UltraNet Communications, Inc.
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4gfg21$iga@caesar.ultra.net>
  9. References: <01BAEFD6.AD7E8620@dino.int.com> <KANZE.96Feb1141158@slsvewt.lts.sel.alcatel.de> <4eto87$9kf@hermes.synopsys.com> <KANZE.96Feb9171756@gabi.gabi-soft.fr>
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: Wed, 21 Feb 1996 16:08:31 GMT
  12. X-Newsreader: Forte Agent .99b.113
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBVAwUBMStc6Ey4NqrwXLNJAQHM6wIAwiEm2bOtiHn2LkKTTvhuKwQdbpooFfgZ
  15.     SF9WJtOqGfwu6jbhxsvpbwS8kWWIUBNUUlW6hKBGHq9ybHHnoPK1ag==
  16.     =CX/x
  17. Originator: austern@isolde.mti.sgi.com
  18.  
  19. kanze@gabi.gabi-soft.fr (J. Kanze) wrote:
  20.  
  21. >In article <4eto87$9kf@hermes.synopsys.com> jbuck@Synopsys.COM (Joe
  22. >Buck) writes:
  23. >> The *language*, not just STL, requires copy constructors that actually
  24. >> copy.  The language automatically uses the copy constructor whenever it
  25. >> needs to make a copy.  The copy constructor is used to return objects from
  26. >> functions and to pass them in by value.  This usaga assumes that you get
  27. >> an actual copy.  Copy constructors can be optimized away in certain
  28. >> circumstances.  Again, this optimization works based on the assumption
  29. >> that a copy constructor does a copy, so you can avoid the copy by
  30. >> constructing the object in the right place.  It also means that having a
  31. >> side effect in the copy constructor (other than something that preserves
  32. >> copy semantics, like reference counting and such) is going to break
  33. >> things.
  34. >
  35. >In all cases where the language (outside of the library) does an
  36. >implicite copy, the object being copied is destructed immediately after,
  37. >before the user can use it for anything else.  So a `copy' that in fact
  38. >`moves' will still work.
  39.  
  40. Hmmm... I take it that you don't consider pass-by-value to be an
  41. implicit copy? Perhaps you're right, but I don't really see where the
  42. implicit vs. explicit question enters into this. I consider it an axiom
  43. that if you assign "a = b" that you can then assume that "a == b" is
  44. true unless a or b are volatile. If you write a copy constructor or
  45. assignment operator such that this is NOT true, then you are asking for
  46. trouble, IMHO. This leaves me with a delema wrt auto_ptr<> because,
  47. while I like what it is trying to do, I don't like the idea of breaking
  48. fundamental axioms in such a flagrant way. This could cause a ripple
  49. effect. I'm not sure what kinds of compiler optimizations might not be
  50. possible or even if certain semantics might become unpredicatable in
  51. this case. Maybe I'm overstating the problem. Auto_ptr<> semantics seem
  52. simple enough on the face of it and maybe this isn't a problem in
  53. reality. (Programming, especially in C++, is not expected to be the same
  54. as mathmatics, after all.)
  55.  
  56. -------------------------------------------------------------
  57. Pablo Halpern                   phalpern@truffle.ultranet.com
  58.  
  59. I am self-employed. Therefore, my opinions *do* represent 
  60. those of my employer.
  61. ---
  62. [ To submit articles: Try just posting with your newsreader.  If that fails,
  63.                       use mailto:std-c++@ncar.ucar.edu
  64.   FAQ:    http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  65.   Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  66.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  67. ]
  68.